'''
Created on 2011-6-17

@author: Administrator
'''
from mongokit import Document

class Selection(Document):
    structure = {
        'name': unicode,
        'text': unicode,
        'type': unicode,
        'url': unicode,
    }
#    validators = {
#        'name': max_length(50),
#        'email': max_length(120)
#    }
    use_dot_notation = True
    def __repr__(self):
#        return '<Selections %r>' % (self.name)
         return self
    
def max_length(length):
    def validate(value):
        if len(value) <= length:
            return True
        raise Exception('%s must be at most %s characters long' % length)
    return validate
